using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    public partial class LinkUserStudentAttributeComponent
    {

        /// <summary>
        /// Selects all records from the database table based on a foreign key.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public List<LinkUserStudentAttribute> SelectAllWUserIdStudentAttributeId(int StudentAttributeId, int UserId, string sortExpression)
        {
            List<LinkUserStudentAttribute> listLinkUserStudentAttribute = new List<LinkUserStudentAttribute>();
            PlacementManager.DAL.LinkUserStudentAttribute_DAL o = new PlacementManager.DAL.LinkUserStudentAttribute_DAL();
            o.StudentAttributeId = StudentAttributeId;
            DataSet ds = o.SelectAllWUserIdStudentAttributeId(UserId);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listLinkUserStudentAttribute.Add(new LinkUserStudentAttribute((int)row["UserStudentAttributeId"], (int)row["UserId"], (int)row["StudentAttributeId"], (DateTime)row["ExpiryDate"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"]));
            }
            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }
            listLinkUserStudentAttribute.Sort(new LinkUserStudentAttributeComparer(sortExpression));
            return listLinkUserStudentAttribute;
        }
	}
}
